package com.ruoyi.framework.weChat.social;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.social.security.SocialAuthenticationFilter;
import org.springframework.social.security.SpringSocialConfigurer;

import javax.swing.*;

/**
 * @Classname BaseSpringSocialConfigurer
 * @Description TODO
 * @Author h21448-hxtq
 * @Date 2020-04-01 17 : 25
 * @Version 1.0
 */
public class BaseSpringSocialConfigurer extends SpringSocialConfigurer {

    private String filterProcessesUrl;
    @Autowired
    private AuthenticationSuccessHandler baseAuthenticationSuccessHandler;

    public BaseSpringSocialConfigurer(String filterProcessesUrl) {
        this.filterProcessesUrl = filterProcessesUrl;
    }

    @Override
    protected <T> T postProcess(T object) {
        SocialAuthenticationFilter filter = (SocialAuthenticationFilter) super.postProcess(object);
        filter.setFilterProcessesUrl(filterProcessesUrl);
        filter.setSignupUrl("/socialSignUp");
        filter.setAuthenticationSuccessHandler(baseAuthenticationSuccessHandler);
        return (T) filter;
    }
}
